package com.excel.model;

import com.excel.CELL;
import com.excel.TableModel;

/**
 * 二维数组
 * @author mike
 *
 */
public class TableExcelModel extends ExcelModelIFace{
	private int srcRowIndex;
	private int srcColIndex;
	//方式 0：正向 1：反向
	//private int flag;
	private int rows = -1;
	private int cols = -1;
	private  String[][] data = null;
	
	
	public TableExcelModel(TableModel tableModel, int srcRowIndex, int srcColIndex, int rows, int cols) {
		super();
		
		this.tableModel = tableModel;
		this.srcRowIndex = srcRowIndex;
		this.srcColIndex = srcColIndex;
		int tableRowIndex  = tableModel.rowIndex;
		if(rows<0) {
			this.rows = tableModel.cells.length-(srcRowIndex) + (rows+1);
		}
		
		this.cols = cols;
	}


	public void extract() {
		data = new String[rows][cols];		
		for(int i=0; i<this.rows; i++) {
			for(int j=0; j<cols; j++) {
				CELL cell = this.tableModel.cells[this.srcRowIndex+i][this.srcColIndex+j];
				data[i][j] = cell.aTD.getAttribute("vv");
			}
		}
	}


	public String[][] getData() {
		return data;
	}
	
}
